//
//  MVVMController.m
//  PrintJob
//
//  Created by blank on 2017/5/8.
//  Copyright (c) 2017 CYN. All rights reserved.
//

#import "MVVMController.h"
#import "MVVMPaper.h"
#import "MVVMView.h"
#import "MVVMViewModel.h"


@interface MVVMController ()

@property(nonatomic, retain) MVVMPaper *mvvmPaper;

@property(nonatomic, retain) MVVMView *mvvmView;

@property(nonatomic, retain) MVVMViewModel *mvvmViewModel;

@end

@implementation MVVMController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self.view setBackgroundColor:[UIColor grayColor]];
    [self.mvvmView setMvvmViewModel:self.mvvmViewModel];

}

- (MVVMPaper *)mvvmPaper {
    if (!_mvvmPaper) {
        _mvvmPaper = [[MVVMPaper alloc] init];
        [_mvvmPaper setContent:@"line 0"];
    }
    return _mvvmPaper;
}

- (MVVMView *)mvvmView {
    if (!_mvvmView) {
//        _mvvmView = [[MVVMView alloc] initWithFrame:self.view.bounds];
        _mvvmView = [[MVVMView alloc] init];
        [_mvvmView setFrame:self.view.bounds];
        [self.view addSubview:_mvvmView];
    }
    return _mvvmView;
}

- (MVVMViewModel *)mvvmViewModel {
    if (!_mvvmViewModel) {
        _mvvmViewModel = [[MVVMViewModel alloc] init];

        [_mvvmViewModel setMvvmPaper:self.mvvmPaper];
    }
    return _mvvmViewModel;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
